<template>
    <h3 style="text-align: center;" >
        添加用户功能
    </h3>
    <table class="table table-bordered" border="1">
        <tr>
            <td>
                用户名
            </td>
            <td>
                <input type="text" v-model="Info.P_Name" placeholder="请输入用户名">
            </td>
        </tr>
        <tr>
            <td>
                密码
            </td>
            <td>
                <input type="password" v-model="Info.P_Pwd" placeholder="请输入密码">
            </td>
        </tr>
        <tr style="text-align: center;">
            <td colspan="2">
                <button class="btn btn-primary" @click="Adduser">添加</button>
            </td>
        </tr>
    </table>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const router = useRouter();
//双向绑定注册
const Info=ref({
    P_Id:0,
    P_Name:'',
    P_Pwd:'',
    P_State:'',
    P_Dele:'',
})
import axios from 'axios';
//添加
const Adduser=()=>{
    axios.post('https://localhost:44369/api/Peoples/AddPeopleLohin',
    {
        P_Id:Info.value.P_Id,
        P_Name:Info.value.P_Name,
        P_Pwd:Info.value.P_Pwd,
        P_State:Info.value.P_State, 
        P_Dele:Info.value.P_Dele,

    }).then((res)=>{
        if(res.data>0)
        {
            alert('添加成功');
            router.push('/Showlookpeoplexx');
        }
        else{
            alert('添加失败');
        }
        console.log(res);
    })
}
</script>